package cn.appsys.service.backend;

import cn.appsys.dao.backenduser.BackendUserMapper;
import cn.appsys.pojo.BackendUser;
import cn.appsys.pojo.DevUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BackendUserServiceImpl implements BackendUserService {
	@Resource
	private BackendUserMapper mapper;
	
	@Override
	public BackendUser login(String userCode, String userPassword) throws Exception {
		BackendUser user = null;
		user = mapper.getLoginUser(userCode);
		//匹配密码
		if(null != user){
			if(!user.getUserPassword().equals(userPassword))
				user = null;
		}
		return user;
	}

    @Override
    public int getUserCheckInfoCount(String queryUserName) {
		int res = -1;
        if (queryUserName == null || "".equals(queryUserName)){
        	res = mapper.getCount();
		}else {
        	res = mapper.getUserCheckListCount(queryUserName);
		}
        return res;

    }

	@Override
	public List<DevUser> getUserCheckInfoList(String queryUserName, Integer currentPageNo, int pageSize) {

		return mapper.getUserCheckInfoList(queryUserName,(currentPageNo-1)*pageSize,pageSize);

	}

}
